<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Server Status Check</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
            background-color: #f8f8f8;
            color: #333;
        }
        .message {
            text-align: center;
        }
        .message h1 {
            font-size: 3em;
            margin: 0;
        }
        .message p {
            font-size: 1.2em;
        }
    </style>
    <script>
        document.addEventListener("DOMContentLoaded", function () {
            let serverUrl = "pay.615mc.cn"; // 服务器地址（无协议和路径部分）
            let baseUrl = "http://615mc.cn/"; // 基础URL
            let fullServerUrl = `${window.location.protocol}//${serverUrl}`; // 根据当前协议构建完整URL

            // 检测服务器状态
            function checkServerStatus() {
                fetch(`${baseUrl}${serverUrl}`, { method: "HEAD" })
                    .then(response => {
                        if (response.ok) {
                            // 如果服务器在线，重定向到服务器
                            window.location.href = fullServerUrl;
                        } else {
                            // 显示404信息
                            show404();
                        }
                    })
                    .catch(() => {
                        // 如果请求失败，显示404信息
                        show404();
                    });
            }

            // 显示404信息
            function show404() {
                const message = document.querySelector(".message");
                message.innerHTML = `
                    <h1>404</h1>
                    <p>Server is currently offline.</p>
                `;
            }

            // 开始检测
            checkServerStatus();
        });
    </script>
</head>
<body>
    <div class="message">
        <h1>Checking server status...</h1>
        <p>Please wait while we check the server availability.</p>
    </div>
</body>
</html>
